<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>QCNSim: QcnSim/ConstantRateTrafficGenerator.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">QCNSim
   </div>
   <div id="projectbrief">Simulator for Quake-Catcher Network</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d21be12960473ba5c51e5f9beea3525e.html">QcnSim</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">ConstantRateTrafficGenerator.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_constant_rate_traffic_generator_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_constant_rate_traffic_generator_8h.html">ConstantRateTrafficGenerator.h</a>&quot;</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#ab4955896e6cceda03ed77653d8a283c7">   38</a></span>&#160;<a class="code" href="class_constant_rate_traffic_generator.html#ab4955896e6cceda03ed77653d8a283c7">ConstantRateTrafficGenerator::ConstantRateTrafficGenerator</a>(<a class="code" href="class_simulator_globals.html">SimulatorGlobals</a> &amp;simulatorGlobals, <a class="code" href="class_scheduler.html">Scheduler</a> &amp;scheduler, <a class="code" href="_event_type_8h.html#a2628ea8d12e8b2563c32f05dc7fff6fa">EventType</a> eventType, std::shared_ptr&lt;Entity&gt; tokenContents,</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        std::shared_ptr&lt;Entity&gt; source, std::shared_ptr&lt;Entity&gt; destination, <span class="keywordtype">int</span> priority, <span class="keywordtype">double</span> interval): <a class="code" href="class_traffic_generator.html">TrafficGenerator</a>(simulatorGlobals, scheduler, eventType, tokenContents,</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        source, destination, priority), interval(interval) {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;}</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#a446a16fedee30afbcb18ecb98f0457cf">   53</a></span>&#160;std::shared_ptr&lt;Token&gt; <a class="code" href="class_constant_rate_traffic_generator.html#a446a16fedee30afbcb18ecb98f0457cf">ConstantRateTrafficGenerator::createInstanceTrafficEvent</a>(<span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="comment">// Creates a token and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(recordRoute);</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordflow">if</span> (token != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, token));</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    }</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="keywordflow">return</span> token;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;}</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div>
<div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#ad81a1b20f608e99b806174375508459e">   74</a></span>&#160;std::shared_ptr&lt;Token&gt; <a class="code" href="class_constant_rate_traffic_generator.html#a446a16fedee30afbcb18ecb98f0457cf">ConstantRateTrafficGenerator::createInstanceTrafficEvent</a>(std::shared_ptr&lt;Entity&gt; tokenContents, <span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="comment">// Creates a token and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(tokenContents, recordRoute);</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    <span class="keywordflow">if</span> (token != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, token));</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    }</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <span class="keywordflow">return</span> token;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;}</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div>
<div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#ab33d71d2137700d034cb9a0d372d39b0">   95</a></span>&#160;std::shared_ptr&lt;Token&gt; <a class="code" href="class_constant_rate_traffic_generator.html#a446a16fedee30afbcb18ecb98f0457cf">ConstantRateTrafficGenerator::createInstanceTrafficEvent</a>(std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; explicitRoute, <span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    <span class="comment">// Creates a token and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(explicitRoute, recordRoute);</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <span class="keywordflow">if</span> (token != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, token));</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    }</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <span class="keywordflow">return</span> token;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;}</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;</div>
<div class="line"><a name="l00117"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#a36affa48c090cc49ea429c975c1450c3">  117</a></span>&#160;std::shared_ptr&lt;Token&gt; <a class="code" href="class_constant_rate_traffic_generator.html#a446a16fedee30afbcb18ecb98f0457cf">ConstantRateTrafficGenerator::createInstanceTrafficEvent</a>(std::shared_ptr&lt;Entity&gt; tokenContents, std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; explicitRoute, <span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="comment">// Creates a token and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(tokenContents, explicitRoute, recordRoute);</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    <span class="keywordflow">if</span> (token != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, token));</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    }</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="keywordflow">return</span> token;</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;}</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;</div>
<div class="line"><a name="l00131"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#a0a81c19b372ba404117f35e552bebe08">  131</a></span>&#160;<span class="keywordtype">double</span> <a class="code" href="class_constant_rate_traffic_generator.html#a0a81c19b372ba404117f35e552bebe08">ConstantRateTrafficGenerator::getInterval</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>;</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;}</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;</div>
<div class="line"><a name="l00143"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#ae32f3ee33afd2117c9c1eafd040f103b">  143</a></span>&#160;std::shared_ptr&lt;ProtocolDataUnit&gt; <a class="code" href="class_constant_rate_traffic_generator.html#ae32f3ee33afd2117c9c1eafd040f103b">ConstantRateTrafficGenerator::createInstanceTrafficEventPdu</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pduSize, <span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    <span class="comment">// Creates a PDU and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    <span class="comment">// Notice that the base class member function &quot;createInstance...&quot; is used here instead of the derived override:</span></div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    <span class="comment">// the derived override schedules an event, and that is undesired here, since an event can only be scheduled &quot;after&quot; the PDU is created.</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(recordRoute);</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="keywordflow">if</span> (token == <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    }</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    <span class="comment">//std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(new ProtocolDataUnit(TrafficGenerator::createInstanceTrafficEvent(recordRoute), pduSize));</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(<span class="keyword">new</span> <a class="code" href="class_protocol_data_unit.html">ProtocolDataUnit</a>(token, pduSize));</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;    <span class="keywordflow">if</span> (pdu != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, pdu));</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    }</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    <span class="keywordflow">return</span> pdu;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;}</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;</div>
<div class="line"><a name="l00168"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#af6e04c1cdc6d0065ff57832edbda2921">  168</a></span>&#160;std::shared_ptr&lt;ProtocolDataUnit&gt; <a class="code" href="class_constant_rate_traffic_generator.html#ae32f3ee33afd2117c9c1eafd040f103b">ConstantRateTrafficGenerator::createInstanceTrafficEventPdu</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pduSize, std::shared_ptr&lt;Entity&gt; pduContents,</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;                                                                                           <span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    <span class="comment">// Creates a PDU and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(pduContents, recordRoute);</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;    <span class="keywordflow">if</span> (token == <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    }</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;    <span class="comment">//std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(new ProtocolDataUnit(TrafficGenerator::createInstanceTrafficEvent(pduContents, recordRoute), pduSize));</span></div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(<span class="keyword">new</span> <a class="code" href="class_protocol_data_unit.html">ProtocolDataUnit</a>(token, pduSize));</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    <span class="keywordflow">if</span> (pdu != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, pdu));</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    }</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;    <span class="keywordflow">return</span> pdu;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;}</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;</div>
<div class="line"><a name="l00192"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#aa8d7770fcb50e452480ec5ee1bc057e3">  192</a></span>&#160;std::shared_ptr&lt;ProtocolDataUnit&gt; <a class="code" href="class_constant_rate_traffic_generator.html#ae32f3ee33afd2117c9c1eafd040f103b">ConstantRateTrafficGenerator::createInstanceTrafficEventPdu</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pduSize, std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; explicitRoute,</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;                                                                                           <span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    <span class="comment">// Creates a PDU and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(explicitRoute, recordRoute);</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;    <span class="keywordflow">if</span> (token == <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;    }</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    <span class="comment">//std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(new ProtocolDataUnit(TrafficGenerator::createInstanceTrafficEvent(explicitRoute, recordRoute), pduSize));</span></div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(<span class="keyword">new</span> <a class="code" href="class_protocol_data_unit.html">ProtocolDataUnit</a>(token, pduSize));</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    <span class="keywordflow">if</span> (pdu != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, pdu));</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;    }</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    <span class="keywordflow">return</span> pdu;</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;}</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;</div>
<div class="line"><a name="l00217"></a><span class="lineno"><a class="line" href="class_constant_rate_traffic_generator.html#ae5c79bec7f8c30b70c6e7b8ee8e1c04f">  217</a></span>&#160;std::shared_ptr&lt;ProtocolDataUnit&gt; <a class="code" href="class_constant_rate_traffic_generator.html#ae32f3ee33afd2117c9c1eafd040f103b">ConstantRateTrafficGenerator::createInstanceTrafficEventPdu</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pduSize, std::shared_ptr&lt;Entity&gt; tokenContents,</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;                                                                                           std::vector&lt;std::shared_ptr&lt;Entity&gt;&gt; explicitRoute,</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;                                                                                           <span class="keywordtype">bool</span> recordRoute) {</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    <span class="comment">// Creates a PDU and assigns it class member values and a unique ID obtained from simulatorGlobals.</span></div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;    std::shared_ptr&lt;Token&gt; token = <a class="code" href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a>(tokenContents, explicitRoute, recordRoute);</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;    <span class="keywordflow">if</span> (token == <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;        <span class="keywordflow">return</span> <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;    }</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;    <span class="comment">//std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(new ProtocolDataUnit(TrafficGenerator::createInstanceTrafficEvent(tokenContents, explicitRoute, recordRoute), pduSize));</span></div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;    std::shared_ptr&lt;ProtocolDataUnit&gt; pdu(<span class="keyword">new</span> <a class="code" href="class_protocol_data_unit.html">ProtocolDataUnit</a>(token, pduSize));</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    <span class="keywordflow">if</span> (pdu != <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;        <a class="code" href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">scheduler</a>.<a class="code" href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">schedule</a>(<a class="code" href="class_event.html">Event</a>(<a class="code" href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">interval</a>, <a class="code" href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">eventType</a>, pdu));</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    }</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    <span class="keywordflow">return</span> pdu;</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;}</div>
<div class="ttc" id="class_protocol_data_unit_html"><div class="ttname"><a href="class_protocol_data_unit.html">ProtocolDataUnit</a></div><div class="ttdoc">Protocol Data Unit class. </div><div class="ttdef"><b>Definition:</b> <a href="_protocol_data_unit_8h_source.html#l00033">ProtocolDataUnit.h:33</a></div></div>
<div class="ttc" id="_event_type_8h_html_a2628ea8d12e8b2563c32f05dc7fff6fa"><div class="ttname"><a href="_event_type_8h.html#a2628ea8d12e8b2563c32f05dc7fff6fa">EventType</a></div><div class="ttdeci">EventType</div><div class="ttdoc">EventType enum class. </div><div class="ttdef"><b>Definition:</b> <a href="_event_type_8h_source.html#l00029">EventType.h:29</a></div></div>
<div class="ttc" id="class_scheduler_html"><div class="ttname"><a href="class_scheduler.html">Scheduler</a></div><div class="ttdoc">Scheduler class. </div><div class="ttdef"><b>Definition:</b> <a href="_scheduler_8h_source.html#l00058">Scheduler.h:58</a></div></div>
<div class="ttc" id="_constant_rate_traffic_generator_8h_html"><div class="ttname"><a href="_constant_rate_traffic_generator_8h.html">ConstantRateTrafficGenerator.h</a></div></div>
<div class="ttc" id="class_event_html"><div class="ttname"><a href="class_event.html">Event</a></div><div class="ttdoc">Event class. </div><div class="ttdef"><b>Definition:</b> <a href="_event_8h_source.html#l00035">Event.h:35</a></div></div>
<div class="ttc" id="class_constant_rate_traffic_generator_html_ab4955896e6cceda03ed77653d8a283c7"><div class="ttname"><a href="class_constant_rate_traffic_generator.html#ab4955896e6cceda03ed77653d8a283c7">ConstantRateTrafficGenerator::ConstantRateTrafficGenerator</a></div><div class="ttdeci">ConstantRateTrafficGenerator(SimulatorGlobals &amp;simulatorGlobals, Scheduler &amp;scheduler, EventType eventType, std::shared_ptr&lt; Entity &gt; tokenContents, std::shared_ptr&lt; Entity &gt; source, std::shared_ptr&lt; Entity &gt; destination, int priority, double interval)</div><div class="ttdef"><b>Definition:</b> <a href="_constant_rate_traffic_generator_8cpp_source.html#l00038">ConstantRateTrafficGenerator.cpp:38</a></div></div>
<div class="ttc" id="class_constant_rate_traffic_generator_html_a432ffa3b53a793e6829f71fffc06c3ea"><div class="ttname"><a href="class_constant_rate_traffic_generator.html#a432ffa3b53a793e6829f71fffc06c3ea">ConstantRateTrafficGenerator::interval</a></div><div class="ttdeci">double interval</div><div class="ttdoc">Fixed, constant time interval for this generator. </div><div class="ttdef"><b>Definition:</b> <a href="_constant_rate_traffic_generator_8h_source.html#l00037">ConstantRateTrafficGenerator.h:37</a></div></div>
<div class="ttc" id="class_constant_rate_traffic_generator_html_a0a81c19b372ba404117f35e552bebe08"><div class="ttname"><a href="class_constant_rate_traffic_generator.html#a0a81c19b372ba404117f35e552bebe08">ConstantRateTrafficGenerator::getInterval</a></div><div class="ttdeci">double getInterval() const </div><div class="ttdef"><b>Definition:</b> <a href="_constant_rate_traffic_generator_8cpp_source.html#l00131">ConstantRateTrafficGenerator.cpp:131</a></div></div>
<div class="ttc" id="class_scheduler_html_ae84f19f548d606f50fba69d00fe691b1"><div class="ttname"><a href="class_scheduler.html#ae84f19f548d606f50fba69d00fe691b1">Scheduler::schedule</a></div><div class="ttdeci">void schedule(const Event &amp;event)</div><div class="ttdef"><b>Definition:</b> <a href="_scheduler_8cpp_source.html#l00056">Scheduler.cpp:56</a></div></div>
<div class="ttc" id="class_constant_rate_traffic_generator_html_a446a16fedee30afbcb18ecb98f0457cf"><div class="ttname"><a href="class_constant_rate_traffic_generator.html#a446a16fedee30afbcb18ecb98f0457cf">ConstantRateTrafficGenerator::createInstanceTrafficEvent</a></div><div class="ttdeci">std::shared_ptr&lt; Token &gt; createInstanceTrafficEvent(bool recordRoute=false) override</div><div class="ttdef"><b>Definition:</b> <a href="_constant_rate_traffic_generator_8cpp_source.html#l00053">ConstantRateTrafficGenerator.cpp:53</a></div></div>
<div class="ttc" id="class_traffic_generator_html_aa1943a93355f1856e639a0f163413249"><div class="ttname"><a href="class_traffic_generator.html#aa1943a93355f1856e639a0f163413249">TrafficGenerator::createInstanceTrafficEvent</a></div><div class="ttdeci">virtual std::shared_ptr&lt; Token &gt; createInstanceTrafficEvent(bool recordRoute=false)=0</div><div class="ttdef"><b>Definition:</b> <a href="_traffic_generator_8cpp_source.html#l00075">TrafficGenerator.cpp:75</a></div></div>
<div class="ttc" id="class_traffic_generator_html_a84eef27cdbfa66bbf8c14e0128196a62"><div class="ttname"><a href="class_traffic_generator.html#a84eef27cdbfa66bbf8c14e0128196a62">TrafficGenerator::eventType</a></div><div class="ttdeci">EventType eventType</div><div class="ttdoc">Event type that this generator will produce. </div><div class="ttdef"><b>Definition:</b> <a href="_traffic_generator_8h_source.html#l00046">TrafficGenerator.h:46</a></div></div>
<div class="ttc" id="class_constant_rate_traffic_generator_html_ae32f3ee33afd2117c9c1eafd040f103b"><div class="ttname"><a href="class_constant_rate_traffic_generator.html#ae32f3ee33afd2117c9c1eafd040f103b">ConstantRateTrafficGenerator::createInstanceTrafficEventPdu</a></div><div class="ttdeci">std::shared_ptr&lt; ProtocolDataUnit &gt; createInstanceTrafficEventPdu(unsigned int pduSize, bool recordRoute=false) override</div><div class="ttdoc">Creates an instance of constant rate traffic event with PDU. </div><div class="ttdef"><b>Definition:</b> <a href="_constant_rate_traffic_generator_8cpp_source.html#l00143">ConstantRateTrafficGenerator.cpp:143</a></div></div>
<div class="ttc" id="class_traffic_generator_html_a9569cd494b926b84f384c7380349d51a"><div class="ttname"><a href="class_traffic_generator.html#a9569cd494b926b84f384c7380349d51a">TrafficGenerator::scheduler</a></div><div class="ttdeci">Scheduler &amp; scheduler</div><div class="ttdoc">Reference to Scheduler object, such that traffic generators may schedule their events. </div><div class="ttdef"><b>Definition:</b> <a href="_traffic_generator_8h_source.html#l00044">TrafficGenerator.h:44</a></div></div>
<div class="ttc" id="class_simulator_globals_html"><div class="ttname"><a href="class_simulator_globals.html">SimulatorGlobals</a></div><div class="ttdoc">Simulator-scope variables and parameters. </div><div class="ttdef"><b>Definition:</b> <a href="_simulator_globals_8h_source.html#l00158">SimulatorGlobals.h:158</a></div></div>
<div class="ttc" id="class_traffic_generator_html"><div class="ttname"><a href="class_traffic_generator.html">TrafficGenerator</a></div><div class="ttdoc">TrafficGenerator parent class. </div><div class="ttdef"><b>Definition:</b> <a href="_traffic_generator_8h_source.html#l00042">TrafficGenerator.h:42</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Jan 6 2014 12:30:36 for QCNSim by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
